<!--
* @description 
* @fileName userReal.vue
* @author huangyu
* @date 2023/02/15 21:11:29
!-->
<template>
    <div class="zx-container">
        <div v-if="powerRoleGM">
            <el-form :inline="true" class="otor_form otor_form_search">
                <el-form-item label="游戏名称">
                    <el-input placeholder="游戏名称" v-model="gameName"></el-input>
                </el-form-item>
                <el-form-item label="账号">
                    <el-input placeholder="账号" v-model="gameCode"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="getData">查询</el-button>
                </el-form-item>
            </el-form>
            <el-table :data="list">
                <el-table-column type="index" width="50" label="序号"></el-table-column>
                <el-table-column label="游戏名称" prop="gameName"></el-table-column>
                <el-table-column label="账号" prop="gameCode"></el-table-column>
                <el-table-column label="图片" prop="gameCode">
                    <template slot-scope="scope">
                        <el-image 
                            v-if="scope.row.ImageUrl" 
                            style="height: 120px"
                            :src="scope.row.ImageUrl" >
                        </el-image>
                    </template>
                </el-table-column>
                <el-table-column label="状态">
                    <template slot-scope="scope">
                        {{scope.row.status==0?'待审核':scope.row.status==1?'审核通过':scope.row.status==-1?'审核拒绝':''}}
                    </template>
                </el-table-column>
                <el-table-column label="操作">
                    <template slot-scope="scope">
                        <el-button type="success" size="mini" @click="clickUpdate(scope.row._id,1)">审核通过</el-button>
                        <el-button type="danger" size="mini" @click="clickUpdate(scope.row._id,-1)">审核拒绝</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <pagination
            :total="total"
            :current-page="pageindex"
            :display="pagesize"
            @pagechange="pagechange"
            ></pagination>
        </div>
    </div>
</template>

<script>
import { get } from '@/common/app.js'
import pagination from "@/components/common/pagination.vue";

export default {
    components: { pagination },
    data() {
        return {
            list: [],
            gameName: "",
            gameCode: "",
            pageindex: 1,
            pagesize: 20,
            total: 0,
            powerRoleGM: this.$power.roleAction('GM'),
        }
    },
    mounted() {
        if(this.token){
            this.getDetail()
        }
    },
    methods: {
        clickUpdate(_id,value){
            let params = {
                type: 'getUser',
                api: 'api-user-real-update',
                data: {
                    _id: _id,
                    status: value,
                },
            }
            get('game', params).then(res => {
                if (res) {
                    console.log(res)
                }
            })
        },
        getData(){
            let params = {
                type: 'getUser',
                api: 'api-user-real-list',
                data: {
                    gameName: this.gameName,
                    gameCode: this.gameCode,
                    pageIndex: this.pageindex,
                    pageSize: this.pagesize,
                },
            }
            get('game', params).then(res => {
                if (res) {
                    // console.log(res)
                    this.list = res.list
                    this.total = res.total
                }
            })
        },
        
        pagechange: function(currentPage) {
            this.pageindex = currentPage;
            this.getData();
        },
    },
}
</script>

<style scoped>

</style>